package com.jianzong.lingxuan.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @auth Leiwenlong
 * @since 2021/10/16
 * @
 */
@Getter
@AllArgsConstructor
public enum CaptchaEnum {
    NOT_ERROR(0000,"无异常，代表成功"),
    SERVICE_ERROR(9999,"服务器内部异常"),
    NOT_PARAMETER(0011,"参数不能为空"),
    MSG_ISVAILD(6110,"验证码已失效，请重新获取"),
    VERIFICATION_ERROR(6111,"验证失败"),
    MSG_ERROR(6112,"获取验证码失败,请联系管理员"),
    CHECK_PATH(6113,"底图未初始化成功，请检查路径"),
    REQ_OVERRUN(6210,"get接口请求次数超限，请稍后再试!"),
    INVALID_REQUEST(6206,"无效请求，请重新获取验证码"),
    INTERFACE_ERROR_MONY(6202,"接口验证失败数过多，请稍后再试"),
    CHECK(6204,"check接口请求次数超限，请稍后再试!");

    //验证码校验失败，返回信息告诉前端
    //repCode  0000  无异常，代表成功
    //repCode  9999  服务器内部异常
    //repCode  0011  参数不能为空
    //repCode  6110  验证码已失效，请重新获取
    //repCode  6111  验证失败
    //repCode  6112  获取验证码失败,请联系管理员
    //repCode  6113  底图未初始化成功，请检查路径
    //repCode  6201  get接口请求次数超限，请稍后再试!
    //repCode  6206  无效请求，请重新获取验证码
    //repCode  6202  接口验证失败数过多，请稍后再试
    //repCode  6204  check接口请求次数超限，请稍后再试!

    Integer code;
    String msg;


    public static CaptchaEnum getByCode(Integer code){
        for(CaptchaEnum transactType : values()){
            if (ObjectUtil.isNotNull(transactType) && transactType.getCode().equals(code) ) {
                //获取指定的枚举
                return transactType;
            }
        }
        return null;
    }
}
